// The complied handlebars templates
// =================================
'use strict';

define([
  'handlebars',
  'text!template/trading/coupon-select.hbs',
  'text!template/trading/coupon-item.hbs',
  'text!template/courseware/fitness-tag-bind.hbs',
  'text!template/courseware/movement-btn.hbs',
  'text!template/courseware/action-group.hbs',
  'text!template/courseware/course-action-group.hbs',
  'text!template/courseware/edit-group.hbs',
  'text!template/mobile-bind.hbs',
  'text!template/mobile-item.hbs',
  'text!template/evaluation/medical-history.hbs',
  'text!template/evaluation/sports-history.hbs',
  'text!template/evaluation/complete-food.hbs',
  'text!template/evaluation/edit-summary.hbs',
  'text!template/evaluation/other-food.hbs',
  'text!template/evaluation/other-item.hbs',
  
], function(Handlebars, couponSelect, couponItem, fitnessTagBind, movementBtn, actionGroup, courseActionGroup, editGroup, mobileBind, mobileItem, medicalHistory, sportsHistory, completeFood, editSummary, otherFood, otherItem) {
  
  Handlebars.registerHelper('currency', function(value, fractionDigits) {
    fractionDigits = fractionDigits || 0
    return (value / 100).toFixed(fractionDigits)
  })

  Handlebars.registerHelper('check', function(oldValue, newValue, trueResult, falseResult) {
    if (oldValue instanceof Array) {

      return oldValue.some(function(item) { return item === newValue }) ? trueResult : (falseResult || '')
    } else {
      return oldValue === newValue ? trueResult : (falseResult || '')
    }
  })
  
  return {
    couponSelectTpl: Handlebars.compile(couponSelect),
    couponItemTpl: Handlebars.compile(couponItem),
    fitnessTagBindTpl: Handlebars.compile(fitnessTagBind),
    movementBtnTpl: Handlebars.compile(movementBtn),
    actionGroupTpl: Handlebars.compile(actionGroup),
    courseActionGroupTpl: Handlebars.compile(courseActionGroup),
    editGroupTpl: Handlebars.compile(editGroup),
    mobileBindTpl: Handlebars.compile(mobileBind),
    mobileItemTpl: Handlebars.compile(mobileItem),
    medicalHistoryTpl: Handlebars.compile(medicalHistory),
    sportsHistoryTpl: Handlebars.compile(sportsHistory),
    completeFoodTpl: Handlebars.compile(completeFood),
    editSummaryTpl: Handlebars.compile(editSummary),
    otherFoodTpl: Handlebars.compile(otherFood),
    otherItemTpl: Handlebars.compile(otherItem),
    
    
    
  }
})